<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>~/itimer/src/directionDetector.vhd.html</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#00008b">----------------------------------------------------------------------------------</font><br>
<font color="#00008b">-- Company: EIFR</font><br>
<font color="#00008b">-- Engineer: Medawar</font><br>
<font color="#00008b">-- </font><br>
<font color="#00008b">-- Create Date:&nbsp;&nbsp;&nbsp;&nbsp;02:21:32 19/04/2009 </font><br>
<font color="#00008b">-- Module Name:&nbsp;&nbsp;&nbsp;&nbsp;wheelHandler - directionDetectorArch </font><br>
<font color="#00008b">-- Project Name:&nbsp;&nbsp; wheelHandler</font><br>
<font color="#00008b">-- Target Devices: Spartan 2 50</font><br>
<font color="#00008b">-- Description:&nbsp;&nbsp;&nbsp;&nbsp; Findet die Richtung von der Rad (&quot;Codeurs incrementaux&quot;)</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Positive dann direction = 0(wheelA = steigene Flanke und wheelB = 0) </font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Negative dann direction = 1(wheelA = 0 und wheelB = steigene Flanke)&nbsp;&nbsp;&nbsp;&nbsp;</font><br>
<font color="#00008b">-- Revision 0.01 - File Created </font><br>
<br>
<font color="#00008b">----------------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>library</b></font>&nbsp;IEEE<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_1164<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_ARITH<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;IEEE<font color="#6a5acd">.</font>STD_LOGIC_UNSIGNED<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<br>
<br>
<font color="#a52a2a"><b>ENTITY</b></font>&nbsp;directionDetector <font color="#a52a2a"><b>IS</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>Port</b></font>&nbsp;<font color="#6a5acd">(</font>&nbsp;wheelInputA <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>IN</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#2e8b57"><b>:=</b></font><font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><font color="#00008b">-- Detektiert den Durchgang eines Zahnes beim ersten Sensor</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wheelInputB <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>IN</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#2e8b57"><b>:=</b></font><font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><font color="#00008b">-- Detektiert den Durchgang eines Zahnes beim ersten Sensor</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clockInput <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>IN</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#2e8b57"><b>:=</b></font><font color="#ff00ff">'0'</font><font color="#6a5acd">;</font>&nbsp;<font color="#00008b">-- Clock vom 10 Khz</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direction <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>OUT</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#2e8b57"><b>:=</b></font><font color="#ff00ff">'0'</font><font color="#6a5acd">);</font><font color="#00008b">-- Positive direction = 0 Negative = 1</font><br>
<font color="#a52a2a"><b>END</b></font>&nbsp;directionDetector<font color="#6a5acd">;</font><br>
<br>
<font color="#a52a2a"><b>ARCHITECTURE</b></font>&nbsp;directionDetector_Arch <font color="#a52a2a"><b>OF</b></font>&nbsp;directionDetector <font color="#a52a2a"><b>IS</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>SIGNAL</b></font>&nbsp;oldWheelInputA<font color="#6a5acd">,</font>oldWheelInputB<font color="#2e8b57"><b>:</b></font><font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#2e8b57"><b>:=</b></font><font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><font color="#00008b">-- Hilfes Variablen um die steigene Flanke zu erkenen</font><br>
<br>
<font color="#a52a2a"><b>BEGIN</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-------------- Process fur die Richtung finden -----------------------</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;calculateDirection<font color="#2e8b57"><b>:</b></font><font color="#a52a2a"><b>PROCESS</b></font><font color="#6a5acd">(</font>clockInput<font color="#6a5acd">,</font>oldWheelInputA<font color="#6a5acd">,</font>oldWheelInputB<font color="#6a5acd">)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>BEGIN</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>IF</b></font>&nbsp;rising_edge<font color="#6a5acd">(</font>clockInput<font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>THEN</b></font>&nbsp;<font color="#00008b">-- Um zu synkrone zu sein.</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>IF</b></font>&nbsp;oldWheelInputA <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#2e8b57"><b>NOT</b></font><font color="#6a5acd">(</font>wheelInputA<font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>THEN</b></font>&nbsp;<font color="#00008b">-- Wen das wert von wheelA hat geändert.</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldWheelInputA <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#6a5acd">(</font>wheelInputA<font color="#6a5acd">);</font><font color="#00008b">-- Wir updaten die Hilfes variabel oldWheelA.</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>IF</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>IF</b></font>&nbsp;oldWheelInputB <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#2e8b57"><b>NOT</b></font><font color="#6a5acd">(</font>wheelInputB<font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>THEN</b></font>&nbsp;<font color="#00008b">-- Wen das wert von wheelA hat geändert.</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldWheelInputB <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#2e8b57"><b>STD_LOGIC</b></font><font color="#6a5acd">(</font>wheelInputB<font color="#6a5acd">);</font><font color="#00008b">-- Wir updaten die Hilfes variabel oldWheelB.</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>IF</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--&nbsp;&nbsp;IF wheelInputA =&nbsp;&nbsp;NOT(oldWheelInputA) AND wheelInputA ='1' THEN </font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--&nbsp;&nbsp;Mit hilfe von diese Kondition wir könen ein steigene Flanke erkenen</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>IF</b></font>&nbsp;wheelInputA <font color="#2e8b57"><b>=</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>NOT</b></font><font color="#6a5acd">(</font>oldWheelInputA<font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>AND</b></font>&nbsp;wheelInputA <font color="#2e8b57"><b>=</b></font><font color="#ff00ff">'1'</font>&nbsp;&nbsp;<font color="#2e8b57"><b>AND</b></font>&nbsp;wheelInputB <font color="#2e8b57"><b>=</b></font><font color="#ff00ff">'0'</font>&nbsp;<font color="#a52a2a"><b>THEN</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;direction <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font>&nbsp;<font color="#00008b">-- Die Richtund ist positive</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>IF</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>IF</b></font>&nbsp;wheelInputB <font color="#2e8b57"><b>=</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>NOT</b></font><font color="#6a5acd">(</font>oldWheelInputB<font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>AND</b></font>&nbsp;wheelInputB <font color="#2e8b57"><b>=</b></font><font color="#ff00ff">'1'</font>&nbsp;<font color="#2e8b57"><b>AND</b></font>&nbsp;wheelInputA <font color="#2e8b57"><b>=</b></font><font color="#ff00ff">'0'</font>&nbsp;<font color="#a52a2a"><b>THEN</b></font>&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;direction <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">;</font>&nbsp;<font color="#00008b">-- Die Richtund ist negative</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>IF</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>IF</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>END</b></font>&nbsp;<font color="#a52a2a"><b>PROCESS</b></font>&nbsp;calculateDirection<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--------------------------------------------------------------------------</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
<font color="#a52a2a"><b>END</b></font>&nbsp;directionDetector_Arch<font color="#6a5acd">;</font><br>
<br>
</font></body>
</html>
